/* 中医风格聊天室样式 */
.chat-container {
  min-height: 100vh;
  background-color: #f9f6f2;
  font-family: 'KaiTi', 'SimSun', serif;
  color: #5c3317;
  display: flex;
  flex-direction: column;
  /* 添加纸张纹理背景 */
  background-image: url('');
  background-repeat: repeat;
}

/* 顶部导航栏 */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 30px;
  background: linear-gradient(to right, #8B4513, #A0522D);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: normal;
  letter-spacing: 2px;
}

.header-actions {
  display: flex;
  gap: 15px;
}

.header-actions button {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: white;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s;
  font-family: 'KaiTi', 'SimSun', serif;
}

.header-actions button:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.back-btn {
  background: rgba(210, 180, 140, 0.3) !important;
}

.logout-btn {
  background: rgba(205, 92, 92, 0.3) !important;
}

/* 内容区域 */
.content {
  flex: 1;
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 20px;
  box-sizing: border-box;
  height: calc(100vh - 70px); /* 减去头部高度 */
}

/* 侧边栏样式 */
.chat-sidebar {
  width: 250px;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(139, 69, 19, 0.1);
  margin-right: 20px;
  display: flex;
  flex-direction: column;
  border: 1px solid #D2B48C;
  overflow: hidden;
}

.patient-sidebar {
  width: 200px; /* 患者模式下的侧边栏宽度 */
}

.user-info {
  padding: 20px;
  text-align: center;
  background-color: #FFF8DC;
  border-bottom: 1px solid #D2B48C;
}

.user-info h3 {
  margin: 0 0 5px;
  color: #8B4513;
  font-size: 18px;
  font-weight: normal;
}

.user-info p {
  margin: 0;
  color: #A0522D;
  font-size: 14px;
}

.user-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-list h4 {
  margin: 0;
  padding: 15px;
  color: #8B4513;
  font-size: 16px;
  font-weight: normal;
  border-bottom: 1px solid #F5DEB3;
}

.loading, .empty-list {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100px;
  color: #A0522D;
  font-size: 14px;
}

.patient-items {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.patient-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  border-radius: 6px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.3s;
  background-color: #FFF8DC;
  border: 1px solid transparent;
}

.patient-item:hover {
  background-color: #F0E68C;
  transform: translateY(-2px);
}

.patient-item.active {
  background-color: #F0E68C;
  border: 1px solid #DEB887;
  box-shadow: 0 2px 8px rgba(139, 69, 19, 0.1);
}

.patient-name {
  color: #8B4513;
  font-size: 16px;
}

.patient-status {
  display: flex;
  align-items: center;
}

.unread-badge {
  background-color: #CD5C5C;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 12px;
}

/* 聊天主区域 */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(139, 69, 19, 0.1);
  overflow: hidden;
  border: 1px solid #D2B48C;
}

.patient-chat {
  margin-left: 0; /* 患者模式下没有侧边栏，靠左 */
}

.no-selection {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #A0522D;
  font-size: 18px;
  background-color: #FFF8DC;
  border-radius: 8px;
}

.chat-header {
  padding: 15px 20px;
  background-color: #FFF8DC;
  border-bottom: 1px solid #D2B48C;
}

.chat-header h3 {
  margin: 0;
  color: #8B4513;
  font-size: 18px;
  font-weight: normal;
}

.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  /* 聊天消息区域也使用纸张纹理背景 */
  background-image: url('');
  background-repeat: repeat;
}

.empty-messages {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  color: #A0522D;
  font-size: 16px;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.message-item {
  max-width: 80%;
  display: flex;
  flex-direction: column;
  background-color: #FFF8DC; /* 默认气泡背景 */
  padding: 12px 15px;
  border-radius: 8px;
  position: relative;
  box-shadow: 0 2px 5px rgba(139, 69, 19, 0.1);
  border: 1px solid #DEB887; /* 默认气泡边框 */
  align-self: flex-start; /* 默认靠左 */
}

/* 气泡箭头 */
.message-item::before {
  content: '';
  position: absolute;
  top: 15px;
  left: -8px;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-right: 8px solid #DEB887; /* 默认箭头颜色 */
}

.message-item.message-self {
  align-self: flex-end; /* 自己发送的靠右 */
  background-color: #E6F7FF; /* 自己发送的气泡背景 */
  border-color: #91D5FF; /* 自己发送的气泡边框 */
}

.message-item.message-self::before {
  left: auto;
  right: -8px;
  border-right: none;
  border-left: 8px solid #91D5FF; /* 自己发送的箭头颜色 */
}

.message-sender {
  font-size: 14px;
  color: #8B4513; /* 默认发送者颜色 */
  margin-bottom: 5px;
  font-weight: bold;
}

.message-item.message-self .message-sender {
  color: #1890FF; /* 自己发送的发送者颜色 */
  text-align: right;
}

.message-content {
  font-size: 16px;
  color: #5c3317; /* 默认内容颜色 */
  word-break: break-word;
  line-height: 1.5;
}

.message-item.message-self .message-content {
  color: #333; /* 自己发送的内容颜色 */
}


.message-time {
  font-size: 12px;
  color: #A0522D; /* 默认时间颜色 */
  align-self: flex-end;
  margin-top: 5px;
}

.message-item.message-self .message-time {
  color: #1890FF; /* 自己发送的时间颜色 */
}

.chat-input {
  padding: 15px;
  display: flex;
  border-top: 1px solid #D2B48C;
  background-color: #FFF8DC;
}

.chat-input textarea {
  flex: 1;
  height: 60px;
  padding: 10px;
  border: 1px solid #D2B48C;
  border-radius: 4px;
  resize: none;
  font-family: 'KaiTi', 'SimSun', serif;
  font-size: 16px;
  color: #5c3317;
  background-color: #fff;
}

.chat-input textarea:focus {
  outline: none;
  border-color: #8B4513;
}

.chat-input button {
  margin-left: 10px;
  padding: 0 20px;
  background-color: #8B4513;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s;
  font-family: 'KaiTi', 'SimSun', serif;
  font-size: 16px;
}

.chat-input button:hover {
  background-color: #A0522D;
  transform: translateY(-2px);
}

/* 响应式调整 */
@media (max-width: 768px) {
  .content {
    flex-direction: column;
    padding: 10px;
  }

  .chat-sidebar {
    width: 100%;
    margin-right: 0;
    margin-bottom: 15px;
    max-height: 200px; /* 手机视图下限制高度 */
  }

  .patient-sidebar {
    max-height: 100px; /* 患者模式下手机视图限制高度 */
  }

  .chat-main {
    height: calc(100vh - 300px); /* 减去头部和侧边栏高度 */
  }

  .message-item {
    max-width: 90%;
  }
}